package org.example.springboot.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import org.example.springboot.common.service.impl.BaseServiceImpl;
import org.example.springboot.convert.RationConvert;
import org.example.springboot.dao.RationDao;
import org.example.springboot.entity.Ration;
import org.example.springboot.service.RationService;
import org.example.springboot.vo.RationVO;
import org.springframework.stereotype.Service;

/**
 * 
 *
 * @author Fz
 * @since 1.0.0 2024-07-31
 */
@Service
@AllArgsConstructor
public class RationServiceImpl extends BaseServiceImpl<RationDao, Ration> implements RationService {

    @Override
    public boolean doSaveOrUpdate(JSONObject irrigationTypeMsg, String uuid) {
        RationVO rationVO = JSON.parseObject(JSON.toJSONString(irrigationTypeMsg), RationVO.class);
        Ration ration = RationConvert.INSTANCE.convert(rationVO);
        ration.setIrrigationUnitUuid(uuid);
        return this.saveOrUp(ration);
    }

}